#include <stdio.h>
#include <string.h>
//字符串转整型

int atoi(const char *s)
{
    int result = 0;
    int sign = 1;
    if(s[0] == '-')
    {
        sign = -1;
    }
    while(*s != '\0')
    {
        if(*s <= '9' && *s >= '0')
            result = result * 10 + *s - '0';
        s++;
    }

    return result*sign;
}

//字符串转浮点
float atof(char*s)
{
    int sign = 1;
    float sum = 0.0;
    float integer = 0.0;
    float decimal = 0.0;
    if(s[0] == '-')
    sign = -1;
    char *p = strtok(s,".");
    char *temp = strtok(NULL,".");
    integer = atoi(p);
    for(int i = 0; i < strlen(temp); i++)
    {
        decimal = decimal / 10;
    }
    
    sum = integer + decimal;
    return sum * sign;
}

int main()
{
    char s[] = "-123";
    char f[] = "21.34";
    char *p = strtok(f,".");
    atof(f);
    // printf("%s %s",p,f);
    // printf("%d\n",atoi(s));
    // printf("%f\n",atof(f));

}